package com.team.order.api;

import com.team.common.core.web.domain.AjaxResult;
import com.team.order.api.domain.OrderSubmitDTO;
import com.team.order.api.domain.OrderVO;
import com.team.order.api.domain.RegionOrderStatisticsVO;
import com.team.order.api.domain.RepairReservationDTO;
import com.team.order.api.factory.RemoteAdminOrderFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 订单服务远程调用接口
 * @author 梁国瑞
 * @version 1.0
 */
@FeignClient(contextId = "remoteAdminOrderService", value = "team-order-service", fallbackFactory = RemoteAdminOrderFallbackFactory.class)
public interface RemoteAdminOrderService {
    
    // ==================== 订单管理接口 ====================
    
    /**
     * 查询订单管理列表
     */
    @GetMapping("/admin/order/list")
    AjaxResult getOrderList(@RequestParam("orderDTO") String orderDTO);
    
    /**
     * 获取订单管理详细信息
     */
    @GetMapping("/admin/order/{id}")
    AjaxResult getOrderInfo(@PathVariable("id") Long id);
    
    /**
     * 新增订单管理
     */
    @PostMapping("/admin/order")
    AjaxResult addOrder(@RequestBody String order);
    
    /**
     * 修改订单表信息
     */
    @PutMapping("/admin/order")
    AjaxResult editOrder(@RequestBody String order);
    
    /**
     * 删除订单管理
     */
    @DeleteMapping("/admin/order/{ids}")
    AjaxResult removeOrder(@PathVariable Long[] ids);
    
    // ==================== 用户订单接口 ====================
    
    /**
     * 提交订单
     */
    @PostMapping("/app/order/submit")
    AjaxResult submitOrder(@RequestBody OrderSubmitDTO orderSubmitDTO);
    
    /**
     * 立即支付
     */
    @PostMapping("/app/order/pay")
    AjaxResult payOrder(@RequestParam String orderNo);
    
    /**
     * 查询支付状态
     */
    @GetMapping("/app/order/pay/status/{orderNo}")
    AjaxResult queryPayStatus(@PathVariable String orderNo);
    
    /**
     * 取消支付
     */
    @PostMapping("/app/order/pay/cancel/{orderId}")
    AjaxResult cancelPay(@PathVariable Long orderId);
    
    // ==================== 维修预约接口 ====================
    
    /**
     * 创建维修预约
     */
    @PostMapping("/repair/add")
    AjaxResult addRepair(@RequestBody RepairReservationDTO repairReservation);
    
    /**
     * 修改维修预约
     */
    @PostMapping("/repair/update")
    AjaxResult updateRepair(@RequestBody RepairReservationDTO repairReservation);
    
    /**
     * 查询维修预约列表
     */
    @GetMapping("/repair/list")
    AjaxResult getReservationList(@RequestParam Long merchantId, 
                                 @RequestParam(required = false) String status);
    
    /**
     * 更新维修预约状态
     */
    @PostMapping("/repair/status")
    AjaxResult updateReservationStatus(@RequestParam Long reservationId, 
                                     @RequestParam String status);
    
    /**
     * 获取维修预约详情
     */
    @GetMapping("/repair/{reservationId}")
    AjaxResult getReservationDetail(@PathVariable Long reservationId);
    
    /**
     * 取消维修预约
     */
    @PostMapping("/repair/cancel/{reservationId}")
    AjaxResult cancelReservation(@PathVariable Long reservationId);
    
    // ==================== 订单统计接口 ====================
    
    /**
     * 获取区域订单统计
     */
    @GetMapping("/admin/order/statistics/region")
    AjaxResult getOrderStatisticsByRegion();
    
    // ==================== 模拟支付接口 ====================
    
    /**
     * 模拟支付成功
     */
    @PostMapping("/mock/payment/success/{orderNo}")
    AjaxResult simulatePaymentSuccess(@PathVariable String orderNo);
    
    /**
     * 模拟支付失败
     */
    @PostMapping("/mock/payment/fail/{orderNo}")
    AjaxResult simulatePaymentFail(@PathVariable String orderNo);
    
    /**
     * 查询支付状态
     */
    @GetMapping("/mock/payment/status/{orderNo}")
    AjaxResult queryPaymentStatus(@PathVariable String orderNo);
    
    /**
     * 模拟退款
     */
    @PostMapping("/mock/payment/refund")
    AjaxResult refund(@RequestParam String orderNo, @RequestParam String amount);
    
    /**
     * 清除所有模拟数据
     */
    @PostMapping("/mock/payment/clear")
    AjaxResult clearAllData();
    
    // ==================== 模拟支付回调接口 ====================
    
    /**
     * 模拟支付成功回调
     */
    @PostMapping("/mock/callback/success/{orderNo}")
    String paymentSuccessCallback(@PathVariable String orderNo);
    
    /**
     * 模拟支付失败回调
     */
    @PostMapping("/mock/callback/fail/{orderNo}")
    String paymentFailCallback(@PathVariable String orderNo);
    
    /**
     * 模拟支付宝支付成功回调
     */
    @PostMapping("/mock/callback/alipay/success/{orderNo}")
    String alipaySuccessCallback(@PathVariable String orderNo);
}
